package com.proposition.commons.exam.exception;


import com.proposition.commons.exam.result.Result;
import com.proposition.commons.exam.result.ResultEnum;

/**
 * @Author: 陈玉林
 * @Description: 分数不正确异常类
 * @Date: 2017/8/10 15:52
 */
public class BaseException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    protected Result result;

    public BaseException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        this.result = result;

    }
    public BaseException(Result result) {
        super(result.getMsg());
        this.result = result;
    }
    public BaseException(String examNum, ResultEnum resultEnum) {
        super("<span style='font-weight: bold;color: red'>第" + examNum + "题:</span>"+resultEnum.getMsg());
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg("<span style='font-weight: bold;color: red'>第" + examNum + "题:</span>"+resultEnum.getMsg());
        this.result = result;
    }
    public BaseException(String label,String examNum, ResultEnum resultEnum) {
        super("<span style='font-weight: bold;color: red'>第" + examNum + "题:</span>"+label+","+resultEnum.getMsg());
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg("<span style='font-weight: bold;color: red'>第" + examNum + "题:</span>"+label+","+resultEnum.getMsg());
        this.result = result;
    }

    public void setResult(Result result) {
        this.result = result;
    }

    public Result getResult() {
        return result;
    }

}
